Xbasic
*html_get_attribute Function
Syntax
C result = *HTML_GET_ATTRIBUTE(html as c, attribute as c)
Arguments
- htmlCharacter
An HTML snippet.
- attribute
The name of the attribute to find.
Description
Get the first matching attribute from passed HTML snippet (returns empty string if none was found).
Example
This is a quick way to extract an attribute value from some HTML markup. Consider the following HTML markup:
dim html as c html = <<%html% id="GRID1.V.R2.PICTURE1" onmouseover="$('bp').src=img;" style="height: 1in; cursor: pointer;" src="pictures/5.jpg" title="pictures/5.jpg" onerror="{grid.object}._executeEvent('onImageError',{element: this});" /> %html%
Say you wanted to extract the 'src' attribute from this HTML. A simple string search for the text 'src=' would be wrong because it would get confused by the code for the onmouseover event handler.
dim attr as c attr = *HTML_GET_ATTRIBUTE(html,"src") ? = src="pictures/5.jpg"